package com.wen;

import com.wen.pojo.User;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class Main {
    public static void main(String[] args) throws Exception {
        FileOutputStream os = new FileOutputStream("E:\\test.txt");
        ObjectOutputStream stream = new ObjectOutputStream(os);
        User user = new User();
        user.setId(2);
        user.setName("文");
        stream.writeObject(user);
        stream.close();


        FileInputStream is = new FileInputStream("E:\\test.txt");
        ObjectInputStream inputStream = new ObjectInputStream(is);
        User o = (User) inputStream.readObject();
        System.out.println(o);
    }
}
